package com.papper.common.enums;

/**
 * @Author:Lajiao
 * @Date:2014年7月14日
 * @Time:下午3:49:44
 * @Description:数据状态定义
 */
public enum OrderTypeEnum {
    T0(10, "T0交易", "T0结算", "T0"),
    T1(11, "T1交易", "T1结算", "T1"),
    QD(98, "商户签到", "商户签到", "QD"),
    JH(99, "账户激活", "账户激活", "JH");

    private Integer code;
    private String  name;
    private String  nameSettle;
    private String  type;

    OrderTypeEnum(Integer code, String name, String nameSettle, String type) {
        this.code = code;
        this.name = name;
        this.nameSettle = nameSettle;
        this.type = type;
    }

    public String getNameSettle() {
        return nameSettle;
    }

    public void setNameSettle(String nameSettle) {
        this.nameSettle = nameSettle;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public static String getName(Integer code) {
        if (code == null) {
            return "";
        }
        for (OrderTypeEnum re : OrderTypeEnum.values()) {
            if (re.getCode().equals(code)) {
                return re.getName();
            }
        }
        return "";
    }

    public static String getNameSettle(Integer code) {
        if (code == null) {
            return "";
        }
        for (OrderTypeEnum re : OrderTypeEnum.values()) {
            if (re.getCode().equals(code)) {
                return re.getNameSettle();
            }
        }
        return "";
    }

    public static Integer getCode(String name) {
        if (name == null) {
            return null;
        }
        for (OrderTypeEnum re : OrderTypeEnum.values()) {
            if (name.equals(re.getName())) {
                return re.getCode();
            }
        }
        return null;
    }

    public static Integer getCodeByType(String type) {
        if (type == null) {
            return null;
        }
        for (OrderTypeEnum re : OrderTypeEnum.values()) {
            if (type.equals(re.getType())) {
                return re.getCode();
            }
        }
        return null;
    }

    public static String getTypeByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (OrderTypeEnum re : OrderTypeEnum.values()) {
            if (code.equals(re.getCode())) {
                return re.getType();
            }
        }
        return null;
    }
}
